package com.hardydou.common.result;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：hardy
 * @description：Result工具类
 * @date ：Created in 2020-03-06
 * @Copyright ：Hardydou.com
 */
public class ResultHelper {


    public static <T> Result make(Code code, T data) {
        return new Result<T>(code, data);
    }

    public static <T> Result make(Code code) {
        return new Result<T>(code, null);
    }

    public static <T> Result ok(T data) {
        return make(Code.SUCCESS, data);
    }

    public static Result<Map<String, Object>> ok() {
        return ok(new HashMap<String, Object>());
    }


    public static <T> Result error(T data) {
        return make(Code.FAILURE, data);
    }

    public static Result<Map<String, Object>> error() {
        return error(new HashMap<String, Object>());
    }

}
